//
//  PickUpNetwork.m
//  Shengzhuli
//
//  Created by subook on 2017/8/18.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "PickUpNetwork.h"
#import "GFXNetworkHandle.h"
#import "SZLAccountHelper.h"

NSString * const PickUpPublish = @"auth/add/rule";//捡漏发布Z
NSString * const PickUpMyDetail = @"auth/my/rule/details";//捡漏专区详情
NSString * const PickUpList = @"rule/list";//首页捡漏列表Z
NSString * const PickUpZan = @"auth/rule/praise";//捡漏点赞Z
NSString * const PickUpAddComment = @"auth/add/rule/comment";//添加评论Z
NSString * const PickUpCommentList = @"rule/comment/list";//评论列表Z
NSString * const PickUpCount = @"auth/my/rule/statistics";//我的捡漏帖子统计Z

@implementation PickUpNetwork

+(void)getThreeLabelNumWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableDictionary *))response {
    
    [[GFXNetworkHandle shareHandle] post:PickUpCount params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        dict[@"commentsNumber"] = json[@"result"][@"commentsNumber"];
        dict[@"posts"] = json[@"result"][@"posts"];
        dict[@"praises"] = json[@"result"][@"praises"];
            response(YES,json[@"message"],dict);
        }
    
    } failure:^(NSError *error) {
        
        response(NO,NetworkError,nil);
    }];
}
+(void)getCommentDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableArray *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpList params:parames success:^(id json) {
        NSLog(@"🌺🌺==%@",json);


        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *arr = [NSMutableArray arrayWithArray:json[@"result"]];
            response(YES,json[@"message"],arr);
        }else {
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+(void)getSendCommentWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableArray *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpAddComment params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *arr = [NSMutableArray arrayWithArray:json[@"result"]];
            response(YES,json[@"message"],arr);
        }else {
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+(void)getUpPickWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableArray *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpPublish params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *arr = [NSMutableArray arrayWithArray:json[@"result"]];
            response(YES,json[@"message"],arr);
        }else {
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+(void)getZanWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpZan params:parames success:^(id json) {
        NSLog(@"&&&&&&&&&&%@",json);
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else {
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}
+(void)getMoreCommentWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableArray *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpCommentList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *arr = [NSMutableArray arrayWithArray:json[@"result"]];
            response(YES,json[@"message"],arr);
        }else {
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+(void)getMyPickWithParame:(NSDictionary *)parames response:(void (^)(BOOL, NSString *, NSMutableArray *))response {
    [[GFXNetworkHandle shareHandle] post:PickUpMyDetail params:parames success:^(id json) {
        NSLog(@"🌺%@==%@",parames,json);

        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *arr = [NSMutableArray arrayWithArray:json[@"result"]];
            response(YES,json[@"message"],arr);
        }else {
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

@end
